package com.kay;

import com.kay.dao.UserMapper;
import com.kay.pojo.User;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Test;

import java.io.IOException;
import java.io.InputStream;

/**
 * @Description: MyBatis引入通用Mapper插件测试
 * @Author: Kay
 * @CreateDate: 2021/6/29$ 16:53$
 * @UpdateUser: Kay
 * @UpdateDate: 2021/6/29$ 16:53$
 */
public class MapperTest {
    @Test
    public void test() throws IOException {
        InputStream resourceAsStream = Resources.getResourceAsStream("SqlMapConfig.xml");
        SqlSessionFactory sessionFactory = new SqlSessionFactoryBuilder().build(resourceAsStream);
        SqlSession sqlSession = sessionFactory.openSession(true);
        UserMapper userMapper = sqlSession.getMapper(UserMapper.class);
        User user = new User();
        user.setId(1);
        User user1 = userMapper.selectOne(user);
        System.out.println(user1);

        User insertUser1 = new User(12,"kay");
        userMapper.insert(insertUser1);











































    }
}
